home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / netutils / nbdriv.arj / NETWORK.ASM next >
Assembly Source File  |  1993-10-28  |  21KB  |  888 lines

  1.         name    network
  2.         page    55,132
  3.         title    'NETBIOS1.SYS --- Netbios Driver'
  4. ;====================================================================
  5. ;<M> Module name - network.asm
  6. ;<A> Abstract - character device driver with interface to Netbios
  7. ;<C> Copyright (C) 1993 MicroPlot Systems Co., Stephen F. Bean
  8. ;<C> Released to public Domain October 28, 1993, Stephen F. Bean
  9. ;<D> October 25, 1993
  10. ;<I> Interface - none
  11. ;<R> Revision Record
  12. ;----
  13. ERROR            equ    8000H
  14. BUSY            equ    0200H
  15. DONE            equ    0100H
  16. UNKNOWN         equ    0003H
  17. MAX_COMMAND        equ    16
  18. INVALID_COMMAND     equ    7fh
  19. ADD_NAME        equ    30h
  20. DELETE_NAME        equ    31h
  21. NETBIOS_CALL        equ    10h
  22. NETBIOS_LISTEN        equ    11h
  23. NETBIOS_HANG_UP     equ    12h
  24. NETBIOS_SEND        equ    14h
  25. NETBIOS_RECEIVE     equ    15h
  26. SEND_DATAGRAM        equ    20h
  27. RECEIVE_DATAGRAM    equ    21h
  28. SEND_B_DATAGRAM     equ    22h
  29. RCV_B_DATAGRAM        equ    23h
  30. CANCEL_COMMAND        equ    35h
  31. NCB_ADD_GROUP_NAME    equ    36h
  32. NO_WAIT         equ    80h
  33. ;====================================================================
  34. ;<M> Module name - RequestHeader
  35. ;<A> Abstract - definition of request header
  36. ;<D> October 25, 1993
  37. ;<I> Interface - none
  38. ;<R> Revision Record
  39. ;<R> 1.
  40. ;----
  41. Request     struc
  42.         ;
  43.         Rlength     db    ?    ;+0  length of header
  44.         Unit        db    ?    ;+01 unit number
  45.         Command     db    ?    ;+02 command code in header
  46.         Status        dw    ?    ;+03 return status
  47.         Reserve     db  8 dup (?)    ;+05 reserved area
  48.         Media        db    ?    ;+13 media descriptor
  49.         Address     dd    ?    ;+14 memory address for transfer
  50.         Count        dw    ?    ;+18 byte count
  51.         Sector        dw    ?    ;+20 starting sector
  52.         ;
  53. Request     ends
  54. ;====================================================================
  55. ;<M> Module name - InitRequestHeader
  56. ;<A> Abstract - definition of request header for init call
  57. ;<D> October 25, 1993
  58. ;<I> Interface - none
  59. ;<R> Revision Record
  60. ;<R> 1.
  61. ;----
  62. InitRequest    struc
  63.         ;
  64.         Rlength     db    ?    ;+0  length of header
  65.         UnitNum     db    ?    ;+01 unit number
  66.         CommCode    db    ?    ;+02 command code in header
  67.         InitStat    dw    ?    ;+03 return status
  68.         ResBytes    dq    ?    ;+05 reserved area
  69.         ;
  70. InitRequest    ends
  71.         ;
  72. InitHeader    struc
  73.         ;
  74.         InitDef     db    sizeof(InitRequest) dup (?)
  75.         InitUnit    db    ?
  76.         EndOffset    dw    ?
  77.         EndSegment    dw    ?
  78.         ArgOffset    dw    ?  ;current argument in config.sys
  79.         ArgSegment    dw    ?  ;
  80.         ;
  81. InitHeader    ends
  82. ;====================================================================
  83. ;<M> Module name - NcbDefinition
  84. ;<A> Abstract - definition of NETBIOS NCB
  85. ;<D> October 25, 1993
  86. ;<I> Interface - none
  87. ;<R> Revision Record
  88. ;<R> 1.
  89. ;----
  90. Ncb        struc
  91. NcbCommand    db    00h        ;command field
  92. NcbRetCode    db    00h        ;return status
  93. NcbLsn        db    00h        ;local session number
  94. NcbNum        db    00h        ;name number from AddName
  95. NcbBufferOff    dw    0000h        ;local buffer offset
  96. NcbBufferSeg    dw    0000h        ;local buffer segment
  97. NcbLength    dw    0000h        ;buffer length
  98. NcbCallName    db    16 dup (0)    ;remote node name
  99. NcbName     db    16 dup (0)    ;local name
  100. NcbRto        db    00h        ;receive timeout
  101. NcbSto        db    00h        ;send timeout
  102. NcbPostOff    dw    0000h        ;offset of post routine
  103. NcbPostSeg    dw    0000h        ;segment of post routine
  104. NcbLanaNumber    db    00h        ;adapter number
  105. NcbCmdCmplt    db    00h        ;command pending flag
  106. NcbReserved    db    14 dup (0)    ;reserved bytes
  107. Ncb        ends
  108. ;====================================================================
  109. ;<M> Module name - DEVICE HEADER
  110. ;<A> Abstract - at offset 0 within device driver
  111. ;<D> October 25, 1993
  112. ;<I> Interface - saves address of request header in local block
  113. ;<R> Revision Record
  114. ;<R> 1.
  115. ;----
  116. Code        segment public 'CODE'
  117. Driver        proc    far
  118.         ;
  119.         assume    cs:Code, ds:Code, es:Code
  120.         ;
  121.         org    0h        ;org for device driver = 0
  122.         ;            ;
  123.         dd   -1         ;pointer to next header
  124.         dw   1000100000000000B    ;attribute-char device, does open/close
  125.         dw   Strategy        ;pointer to device "strategy" routine
  126.         dw   EntryPoint     ;pointer to device "interrupt handler"
  127.         DB   'NETBIOS1'         ;8 BYTE DEVICE NAME
  128. ;====================================================================
  129. ;<M> Module name - local_data
  130. ;<A> Abstract - local messages & registers
  131. ;<D> October 25, 1993
  132. ;<I> Interface - none
  133. ;<R> Revision Record
  134. ;<R> 1.
  135. ;----
  136. ReqPtr        dd    ?        ;pointer to data header
  137. OutBufferPtr    db    0
  138. InBufferPtr    db    0
  139. InputBuffer    db    256 dup (0)
  140. OutputSize    db    'XXXX bytes -'
  141. MyName        db    'xxxx'
  142. OutputBuffer    db    256 dup (0)
  143. OBuffPtr    db    0
  144. Ident        db    13,10,'NETWORK.SYS V1.00'
  145.         db    ' (C) 10/25/93 MicroPlot',13,10
  146.         db    'Device Header at '
  147. DHaddr        db    'XXXX:0000'
  148.         db    13,10,0
  149. NetBiosError    db    'NetBios Error # '
  150. HexValue    db    'XXXX',13,10,10,0
  151. OpenFlag    db    0
  152. NetBiosOpen    db    0
  153. DatagramNcb    db    sizeof(Ncb) dup (0)
  154. ReceiveNcb    db    sizeof(Ncb) dup (0)
  155. GroupName    db    'NETSEND_GROUP',0,0,10
  156. NameAdd     db    'NETSEND_GROUP Name Added',13,10,0
  157. NameError    db    'Error Adding Group Name',13,10,0
  158. ;====================================================================
  159. ;<M> Module name - command_table
  160. ;<A> Abstract - table of functions in device driver
  161. ;<D> October 25, 1993
  162. ;<I> Interface - none
  163. ;<R> Revision Record
  164. ;<R> 1.
  165. ;----
  166. CommandTable:
  167.         dw    DeviceInitialize    ;0
  168.         dw    MediaCheck        ;1
  169.         dw    BuildIopb        ;2
  170.         dw    IoctlIn         ;3
  171.         dw    Input            ;4
  172.         dw    NdInput         ;5
  173.         dw    InputStat        ;6
  174.         dw    InputFlush        ;7
  175.         dw    Output            ;8
  176.         dw    OutputVerify        ;9
  177.         dw    OutputStatus        ;10
  178.         dw    OutputFlush        ;11
  179.         dw    IoctlOut        ;12
  180.         dw    DeviceOpen        ;13
  181.         dw    DeviceClose        ;14
  182.         dw    RemovableMedia        ;15
  183.         dw    OutputTillBusy        ;16
  184. ;====================================================================
  185. ;<M> Module name - Strategy
  186. ;<A> Abstract - saves address of request header
  187. ;<D> October 25, 1993
  188. ;<I> Interface - saves address of request header in local block
  189. ;<R> Revision Record
  190. ;<R> 1.
  191. ;====================================================================
  192. Strategy    proc    far
  193.         ;
  194.         mov    word ptr cs: [ReqPtr],bx
  195.         mov    word ptr cs: [ReqPtr+2],es
  196.         ret
  197.         ;
  198. Strategy    endp
  199. ;====================================================================
  200. ;<M> Module name - EntryPoint
  201. ;<A> Abstract - entry point of the device driver
  202. ;<A>        get here with far call from DOS
  203. ;<A>        save all registers and call routine pointed to in header
  204. ;<D> October 25, 1993
  205. ;<I> Interface - none
  206. ;<R> Revision Record
  207. ;<R> 1.
  208. ;====================================================================
  209. EntryPoint    proc    far
  210.         ;
  211.         push    ax
  212.         push    bx
  213.         push    cx
  214.         push    dx
  215.         push    ds
  216.         push    es
  217.         push    di
  218.         push    si
  219.         push    bp
  220.         ;
  221.         push    cs
  222.         pop    ds            ;ds=cs
  223.         ;
  224.         les    di,[ReqPtr]        ;es:di = request header
  225.         mov    bl,es:[di.command]    ;get command code
  226.         xor    bh,bh            ;bh=0
  227.         cmp    bx,MAX_COMMAND        ;
  228.         jle    Intr01            ;
  229.         mov    ax,ERROR+UNKNOWN    ;set error bit & unknown
  230.         jmp    intr02            ;error exit
  231.         ;
  232. Intr01:     shl    bx,1            ;word table
  233.         call    word ptr [bx+CommandTable]
  234.         les    di,[ReqPtr]        ;
  235. Intr02:     or    ax,DONE         ;done bit
  236.         mov    es:[di.Status],ax    ;
  237.         ;
  238.         pop    bp
  239.         pop    si
  240.         pop    di
  241.         pop    es
  242.         pop    ds
  243.         pop    dx
  244.         pop    cx
  245.         pop    bx
  246.         pop    ax
  247.         ret
  248.         ;
  249. EntryPoint    endp
  250. ;====================================================================
  251. ;<M> Module name - DeviceInitialize
  252. ;<A> Abstract - initialize driver
  253. ;<D> October 25, 1993
  254. ;<I> Interface - none
  255. ;<R> Revision Record
  256. ;<R> 1.
  257. ;====================================================================
  258. DeviceInitialize    proc    near
  259.         ;
  260.         push    es
  261.         push    di
  262.         ;
  263.         mov    ax,cs
  264.         mov    bx,offset DHaddr
  265.         call    HexToAscii
  266.         mov    si,offset Ident
  267.         call    PrintString
  268.         ;
  269.         pop    di
  270.         pop    es
  271.         ;
  272.         push    es
  273.         push    di
  274.         ;
  275.         mov    bx,word ptr es:[di.ArgOffset]
  276.         mov    ax,word ptr es:[di.ArgSegment]
  277.         mov    es,ax
  278.         ;
  279. FindName:    mov    al,es:[bx]
  280.         inc    bx
  281.         cmp    al,' '
  282.         je    EndDevName
  283.         jmp    FindName
  284.         ;
  285.         ; put name in local register
  286.         ;
  287. EndDevName:    mov    cx,4
  288.         mov    si,offset MyName
  289. PutName:    mov    al,es:[bx]
  290.         mov    [si],al
  291.         inc    bx
  292.         inc    si
  293.         loop    PutName
  294.         ;
  295.         pop    di
  296.         pop    es
  297.         ;
  298.         mov    word ptr es:[di.Address],offset ModuleEnd
  299.         mov    word ptr es:[di.Address+2],cs
  300.         xor    ax,ax
  301.         ret
  302.         ;
  303. DeviceInitialize    endp
  304. ;====================================================================
  305. ;<M> Module name - MediaCheck
  306. ;<A> Abstract - not used on character drivers
  307. ;<D> October 25, 1993
  308. ;<I> Interface - none
  309. ;<R> Revision Record
  310. ;<R> 1.
  311. ;====================================================================
  312. MediaCheck    proc    near
  313.         ;
  314.         xor    ax,ax
  315.         ret
  316.         ;
  317. MediaCheck    endp
  318. ;====================================================================
  319. ;<M> Module name - BuildIopb
  320. ;<A> Abstract - not used on character drivers
  321. ;<D> October 25, 1993
  322. ;<I> Interface - none
  323. ;<R> Revision Record
  324. ;<R> 1.
  325. ;====================================================================
  326. BuildIopb    proc    near
  327.         ;
  328.         xor    ax,ax
  329.         ret
  330.         ;
  331. BuildIopb    endp
  332. ;====================================================================
  333. ;<M> Module name - IoctlIn
  334. ;<A> Abstract - IOCTL functions not supported
  335. ;<D> October 25, 1993
  336. ;<I> Interface - none
  337. ;<R> Revision Record
  338. ;<R> 1.
  339. ;====================================================================
  340. IoctlIn     proc    near
  341.         ;
  342.         xor    ax,ax
  343.         ret
  344.         ;
  345. IoctlIn     endp
  346. ;====================================================================
  347. ;<M> Module name - Input
  348. ;<A> Abstract - transfers data from the device into the specified
  349. ;<A>        memory buffer.
  350. ;<D> October 25, 1993
  351. ;<I> Interface - Passed to driver:
  352. ;<I>         Unit Code
  353. ;<I>         Command code = 4
  354. ;<I>         Media Descriptor byte
  355. ;<I>         Transfer address
  356. ;<I>         Byte/Sector Count transferred
  357. ;<I>         Starting sector (block dev. only)
  358. ;<I> Interface - Returns
  359. ;<I>         Return Status
  360. ;<I>         Actual bytes or sectors transferred
  361. ;<R> Revision Record
  362. ;<R> 1.
  363. ;====================================================================
  364. Input        proc    near
  365.         ;
  366.         push    es
  367.         push    di
  368.         ;
  369.         mov    word ptr es:[di.Count],0
  370.         mov    al,InBufferPtr
  371.         cmp    al,OutBufferPtr
  372.         je    NoXfer
  373.         ;
  374.         mov    word ptr es:[di.Count],1
  375.         mov    bx,word ptr es:[di.Address]
  376.         mov    ax,word ptr es:[di.Address+2]
  377.         mov    es,ax    ;es:bx->buffer
  378.         ;
  379.         mov    si,offset InputBuffer
  380.         mov    al,OutBufferPtr
  381.         mov    ah,0
  382.         add    si,ax
  383.         mov    al,[si]
  384.         mov    es:[bx],al
  385.         inc    OutBufferPtr
  386.         ;
  387. NoXfer:     pop    es
  388.         pop    di
  389.         ;
  390.         xor    ax,ax
  391.         ret
  392.         ;
  393. Input        endp
  394. ;====================================================================
  395. ;<M> Module name - NdInput
  396. ;<A> Abstract -
  397. ;<D> October 25, 1993
  398. ;<I> Interface - none
  399. ;<R> Revision Record
  400. ;<R> 1.
  401. ;====================================================================
  402. NdInput     proc    near
  403.         ;
  404.         mov    al,0
  405.         cmp    byte ptr InBufferPtr,0
  406.         je    NoNdIn
  407.         mov    al,InBufferPtr
  408.         dec    al
  409.         mov    ah,0
  410.         mov    si,offset InputBuffer
  411.         add    si,ax
  412.         mov    al,[si]
  413. NoNdIn:     mov    byte ptr es:[di.Media],al
  414.         xor    ax,ax
  415.         ret
  416.         ;
  417. NdInput     endp
  418. ;====================================================================
  419. ;<M> Module name - InputStat
  420. ;<A> Abstract -
  421. ;<D> October 25, 1993
  422. ;<I> Interface - none
  423. ;<R> Revision Record
  424. ;<R> 1.
  425. ;====================================================================
  426. InputStat    proc    near
  427.         ;
  428.         xor    ax,ax
  429.         ret
  430.         ;
  431. InputStat    endp
  432. ;====================================================================
  433. ;<M> Module name - InputFlush
  434. ;<A> Abstract -
  435. ;<D> October 25, 1993
  436. ;<I> Interface - none
  437. ;<R> Revision Record
  438. ;<R> 1.
  439. ;====================================================================
  440. InputFlush    proc    near
  441.         ;
  442.         mov    InBufferPtr,0
  443.         xor    ax,ax
  444.         ret
  445.         ;
  446. InputFlush    endp
  447. ;====================================================================
  448. ;<M> Module name - Output
  449. ;<A> Abstract -
  450. ;<D> October 25, 1993
  451. ;<I> Interface - Passed to driver:
  452. ;<I>         Unit Code
  453. ;<I>         Command code = 8
  454. ;<I>         Media Descriptor byte
  455. ;<I>         Transfer address
  456. ;<I>         Byte/Sector Count
  457. ;<I>         Starting sector (block dev. only)
  458. ;<I> Interface - Returns
  459. ;<I>         Return Status
  460. ;<I>         Actual bytes or sectors transferred
  461. ;<R> Revision Record
  462. ;<R> 1.
  463. ;====================================================================
  464. Output        proc    near
  465.         ;
  466.         push    es
  467.         push    di
  468.         ;
  469.         ; put char in buffer - only send if
  470.         ; char is <cr> or if buffer has 256 bytes
  471.         ;
  472.         push    es
  473.         push    di
  474.         ;
  475.         mov    bx,word ptr es:[di.Address]    ;
  476.         mov    ax,word ptr es:[di.Address+2]    ;
  477.         mov    es,ax                ;es:bx -> incoming buffer
  478.         mov    al,es:[bx]            ;get incoming char
  479.         ;
  480.         pop    di
  481.         pop    es
  482.         ;
  483.         cmp    al,0dh                ;is <cr>?
  484.         je    SendDatagram            ;
  485.         cmp    al,20h                ;printable?
  486.         jl    OoXfer                ;ignore other control chars
  487.         mov    si,offset OutputBuffer        ;
  488.         mov    cl,OBuffPtr            ;
  489.         mov    ch,0                ;
  490.         add    si,cx                ;->next buffer pos
  491.         mov    [si],al             ;put in buffer
  492.         inc    cx                ;
  493.         inc    OBuffPtr            ;
  494.         cmp    cx,0fah             ;buffer full?
  495.         jl    OoXfer                ;
  496.         ;
  497.         ; clear out Ncb & put in name
  498.         ;
  499. SendDatagram:    push    di
  500.         push    es
  501.         mov    di,offset DatagramNcb
  502.         call    ClearNcb
  503.         mov    ax,ds
  504.         mov    es,ax
  505.         mov    si,offset GroupName
  506.         mov    di,offset DatagramNcb.NcbCallName
  507.         mov    cx,16
  508.         cld
  509.         rep    movsb
  510.         pop    es
  511.         pop    di
  512.         ;
  513.         ; fill in Ncb
  514.         ;
  515.         mov    al,OBuffPtr            ;get xfer count
  516.         mov    ah,0                ;
  517.         add    ax,4                ;add length of host name
  518.         mov    DatagramNcb.NcbLength,ax    ;put in Ncb
  519.         mov    OBuffPtr,0            ;reset pointer
  520.         mov    ax,offset MyName        ;
  521.         mov    DatagramNcb.NcbBufferOff,ax    ;offset of data buffer
  522.         mov    ax,cs                ;
  523.         mov    DatagramNcb.NcbBufferSeg,ax    ;seg of data buffer
  524.         mov    DatagramNcb.NcbNum,1        ;permanent node #
  525.         mov    ax,cs                ;seg of Ncb
  526.         mov    es,ax                ;
  527.         mov    bx,offset DatagramNcb        ;es:bx -> Ncb
  528.         mov    DatagramNcb.NcbCommand,SEND_DATAGRAM
  529.         ;
  530.         ; Netbios send datagram
  531.         ;
  532.         int    5ch                ;call NETBIOS
  533.         test    al,al                ;test for error
  534.         jz    OoXfer                ;
  535.         mov    bx,offset HexValue        ;
  536.         mov    al,DatagramNcb.NcbCmdCmplt    ;
  537.         mov    ah,0                ;
  538.         call    HexToAscii            ;
  539.         mov    si,offset NetBiosError        ;
  540.         call    PrintString            ;
  541.         ;
  542. OoXfer:     pop    es
  543.         pop    di
  544.         xor    ax,ax
  545.         ret
  546.         ;
  547. Output        endp
  548.         ;
  549. Idx        dw    0
  550. ;====================================================================
  551. ;<M> Module name - OutputVerify
  552. ;<A> Abstract -
  553. ;<D> October 25, 1993
  554. ;<I> Interface - none
  555. ;<R> Revision Record
  556. ;<R> 1.
  557. ;====================================================================
  558. OutputVerify    proc    near
  559.         ;
  560.         jmp    Output
  561.         ;
  562. OutputVerify    endp
  563. ;====================================================================
  564. ;<M> Module name - OutputStatus
  565. ;<A> Abstract -
  566. ;<D> October 25, 1993
  567. ;<I> Interface - none
  568. ;<R> Revision Record
  569. ;<R> 1.
  570. ;====================================================================
  571. OutputStatus    proc    near
  572.         ;
  573.         xor    ax,ax
  574.         ret
  575.         ;
  576. OutputStatus    endp
  577. ;====================================================================
  578. ;<M> Module name - OutputFlush
  579. ;<A> Abstract -
  580. ;<D> October 25, 1993
  581. ;<I> Interface - none
  582. ;<R> Revision Record
  583. ;<R> 1.
  584. ;====================================================================
  585. OutputFlush    proc    near
  586.         ;
  587.         xor    ax,ax
  588.         ret
  589.         ;
  590. OutputFlush    endp
  591. ;====================================================================
  592. ;<M> Module name - IoctlOut
  593. ;<A> Abstract -
  594. ;<D> October 25, 1993
  595. ;<I> Interface - none
  596. ;<R> Revision Record
  597. ;<R> 1.
  598. ;====================================================================
  599. IoctlOut    proc    near
  600.         ;
  601.         xor    ax,ax
  602.         ret
  603.         ;
  604. IoctlOut    endp
  605. ;====================================================================
  606. ;<M> Module name - DeviceOpen
  607. ;<A> Abstract -
  608. ;<D> October 25, 1993
  609. ;<I> Interface - none
  610. ;<R> Revision Record
  611. ;<R> 1.
  612. ;====================================================================
  613. DeviceOpen    proc    near
  614.         ;
  615.         ; check if already open
  616.         ;
  617.         push    es
  618.         push    di
  619.         ;
  620.         cmp    OpenFlag,0
  621.         jne    DevOpenErr
  622.         mov    OpenFlag,1
  623.         ;
  624.         ; check if Netbios receive is already initialized
  625.         ;
  626.         cmp    NetBiosOpen,0
  627.         jne    DevOpenExit
  628.         ;
  629.         ; clear Ncb & put in name
  630.         ;
  631.         mov    di,offset ReceiveNcb
  632.         call    ClearNcb
  633.         mov    ax,ds
  634.         mov    es,ax
  635.         mov    si,offset GroupName
  636.         mov    di,offset ReceiveNcb.NcbName
  637.         mov    cx,16
  638.         cld
  639.         rep    movsb
  640.         ;
  641.         ; add name netbios command
  642.         ;
  643.         mov    ReceiveNcb.NcbCommand,NCB_ADD_GROUP_NAME
  644.         mov    ax,cs
  645.         mov    es,ax
  646.         mov    bx,offset ReceiveNcb
  647.         int    5ch
  648.         test    al,al
  649.         jnz    NetbiosRxErr
  650.         ;
  651.         ; print name add message
  652.         ;
  653.         mov    si, offset NameAdd
  654.         call    PrintString
  655.         mov    NetBiosOpen,1
  656.         call    SetupReceive
  657.         ;
  658. DevOpenExit:    pop    di
  659.         pop    es
  660.         ;
  661.         xor    ax,ax
  662.         ret
  663.         ;
  664. NetbiosRxErr:    mov    si,offset NameError
  665.         call    PrintString
  666.         mov    bx,offset HexValue        ;
  667.         mov    al,ReceiveNcb.NcbCmdCmplt    ;
  668.         mov    ah,0                ;
  669.         call    HexToAscii            ;
  670.         mov    si,offset NetBiosError        ;
  671.         call    PrintString            ;
  672.         ;
  673. DevOpenErr:    mov    ax,ERROR
  674.         pop    di
  675.         pop    es
  676.         ret
  677.         ;
  678. DeviceOpen    endp
  679. ;====================================================================
  680. ;<M> Module name - DeviceClose
  681. ;<A> Abstract -
  682. ;<D> October 25, 1993
  683. ;<I> Interface - none
  684. ;<R> Revision Record
  685. ;<R> 1.
  686. ;====================================================================
  687. DeviceClose    proc    near
  688.         ;
  689.         cmp    OpenFlag,1
  690.         jne    DevCloErr
  691.         mov    OpenFlag,0
  692.         xor    ax,ax
  693.         ret
  694.         ;
  695. DevCloErr:    mov    ax,ERROR
  696.         ret
  697.         ;
  698. DeviceClose    endp
  699. ;====================================================================
  700. ;<M> Module name - RemovableMedia
  701. ;<A> Abstract -
  702. ;<D> October 25, 1993
  703. ;<I> Interface - none
  704. ;<R> Revision Record
  705. ;<R> 1.
  706. ;====================================================================
  707. RemovableMedia    proc    near
  708.         ;
  709.         xor    ax,ax
  710.         ret
  711.         ;
  712. RemovableMedia    endp
  713. ;====================================================================
  714. ;<M> Module name - OutputTillBusy
  715. ;<A> Abstract -
  716. ;<D> October 25, 1993
  717. ;<I> Interface - none
  718. ;<R> Revision Record
  719. ;<R> 1.
  720. ;====================================================================
  721. OutputTillBusy    proc    near
  722.         ;
  723.         xor    ax,ax
  724.         ret
  725.         ;
  726. OutputTillBusy    endp
  727. ;====================================================================
  728. ;<M> Module name - SetupReceive
  729. ;<A> Abstract -
  730. ;<D> October 25, 1993
  731. ;<I> Interface - none
  732. ;<R> Revision Record
  733. ;<R> 1.
  734. ;====================================================================
  735. SetupReceive    proc    near
  736.         ;
  737.         push    es
  738.         push    di
  739.         ;
  740.         mov    ReceiveNcb.NcbLength,256
  741.         mov    ReceiveNcb.NcbBufferOff,offset InputBuffer
  742.         mov    ax,cs
  743.         mov    ReceiveNcb.NcbBufferSeg,ax
  744.         mov    ReceiveNcb.NcbPostOff,offset ReceivePost
  745.         mov    ax,cs
  746.         mov    ReceiveNcb.NcbPostSeg,ax
  747.         mov    ReceiveNcb.NcbCommand,RECEIVE_DATAGRAM+NO_WAIT
  748.         mov    es,ax
  749.         mov    bx,offset ReceiveNcb
  750.         int    5ch
  751.         ;
  752.         pop    di
  753.         pop    es
  754.         ret
  755.         ;
  756. SetupReceive    endp
  757. ;====================================================================
  758. ;<M> Module name - ReceivePost
  759. ;<A> Abstract -
  760. ;<D> October 25, 1993
  761. ;<I> Interface - none
  762. ;<R> Revision Record
  763. ;<R> 1.
  764. ;====================================================================
  765. ReceivePost    proc    far
  766.         ;
  767.         push    ax
  768.         push    bx
  769.         push    cx
  770.         push    dx
  771.         push    si
  772.         push    di
  773.         push    es
  774.         push    ds
  775.         sti
  776.         ;
  777.         mov    ax,cs
  778.         mov    ds,ax
  779.         mov    es,ax
  780.         mov    si,offset InputBuffer
  781.         mov    di,offset MyName
  782.         mov    cx,4
  783.         repe    cmpsb
  784.         jcxz    MyMessage
  785.         ;
  786.         mov    si,offset InputBuffer
  787.         mov    cx,ReceiveNcb.NcbLength
  788.         mov    InBufferPtr,cl
  789.         mov    OutbufferPtr,0
  790. MyMessage:    call    SetupReceive
  791.         ;
  792.         pop    ds
  793.         pop    es
  794.         pop    di
  795.         pop    si
  796.         pop    dx
  797.         pop    cx
  798.         pop    bx
  799.         pop    ax                ;RESTORE THE WORLD
  800.         iret                ;AND RETURN FROM THE POST
  801.         ;
  802. ReceivePost    endp
  803. ;====================================================================
  804. ;<M> Module name - HexToAscii
  805. ;<A> Abstract - converts 16 bit number in AX to 4 digit ASCII
  806. ;<D> October 25, 1993
  807. ;<I> Interface - AX = input value
  808. ;<I>         DS:BX = address of string
  809. ;<R> Revision Record
  810. ;<R> 1.
  811. ;====================================================================
  812. HexToAscii    proc    near
  813.         ;
  814.         push    cx
  815.         push    dx
  816.         mov    dx,4        ;character counter
  817. HexAsc1:    mov    cx,4
  818.         rol    ax,cl
  819.         mov    cx,ax
  820.         and    cx,0fh
  821.         add    cx,'0'
  822.         cmp    cx,'9'
  823.         jbe    HexAsc2
  824.         add    cx,'A'-'9'-1
  825. HexAsc2:    mov    [bx],cl
  826.         inc    bx
  827.         dec    dx
  828.         jnz    HexAsc1
  829.         pop    dx
  830.         pop    cx
  831.         ret
  832.         ;
  833. HexToAscii    endp
  834. ;====================================================================
  835. ;<M> Module name - PrintString
  836. ;<A> Abstract - outputs string pointed to by bx
  837. ;<D> October 25, 1993
  838. ;<I> Interface - DS:SI = address of string
  839. ;<R> Revision Record
  840. ;<R> 1.
  841. ;====================================================================
  842. PrintString    proc    near
  843.         ;
  844.         mov    al,[si]
  845.         inc    si
  846.         cmp    al,0
  847.         je    EnPrStr
  848.         mov    ah,0eh
  849.         mov    bx,0
  850.         push    si
  851.         int    10h
  852.         pop    si
  853.         jmp    PrintString
  854. EnPrStr:    ret
  855.         ;
  856. PrintString    endp
  857. ;===================================================================
  858. ;<M> Module name - ClearNcb
  859. ;<A> Abstract - sets all 64 bytes of Ncb to 0
  860. ;<D> September 27, 1993
  861. ;<I> Interface - on entry di-> Ncb to be cleared
  862. ;<R> Revision Record
  863. ;<R> 1.
  864. ;===================================================================
  865. ClearNcb    proc    near
  866.         ;
  867.         push    cx
  868.         push    ax
  869.         push    es
  870.         mov    ax,ds
  871.         mov    es,ax
  872.         mov    cx,32
  873.         mov    ax,0
  874.         cld
  875.         rep    stosw
  876.         pop    es
  877.         pop    ax
  878.         pop    cx
  879.         ret
  880. ClearNcb    endp
  881.         ;
  882. ModuleEnd    dw    0
  883.         ;
  884. Driver        endp
  885. Code        ends
  886.         ;
  887.         end
  888.